# CFLAGS := -I./ -Wall -Wextra -O2
INC_DIR := -Iinc/ \
		   -I$(SDKCLI_INC)

SRC_DIR := src
OBJ_DIR := obj

# 自动发现源文件
SRC := $(shell find $(SRC_DIRS) -name '*.c')
OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(SRC:.c=.o)))
DEPS = $(OBJS:.o=.d)

all: $(OBJS)

# 编译规则（保留目录结构）
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | obj
	$(CC) $(INC_DIR) -c $< -o $@ $(GDB_FLAG)

# Create build directory
obj:
	mkdir -p $@

# Include dependencies
-include $(DEPS)

# Clean
.PHONY: clean
clean:
	rm -rf $(OBJS) $(DEPS)

# Help
.PHONY: help
help:
	@echo "Usage:"
	@echo "  make     - build project"
	@echo "  make clean - remove build artifacts"

